# encoding:utf-8
import requests
from utils.time_tool.time_control import Getdate

def push_text_message(webhook):
    '''
    发送文本消息
    :param webhook:
    :return:
    '''
    content = {
        "msg_type": "text",
        "content": {
            "text": f'{Getdate().getCurrentday()}' + ' ' + f'{Getdate().getWeekdayToday()}'
                    + "\n 提醒,消息格式：text"
                    + "\n <at user_id='all'>所有人</at> @单个人需要userid"
        }}
    requests.post(url=webhook, json=content, verify=False)

def push_rich_text_message(webhook):
    '''
    发送富文本消息
    :param webhook:
    :return:
    '''
    content = {
        "msg_type": "interactive",
        "card": {
            "elements": [{
                "tag": "div",
                "text": {
                    "content": "**出错啦**，sip电话报了点小错",
                    "tag": "lark_md"
                }
            }, {
                "actions": [{
                    "tag": "button",
                    "text": {
                        "content": "详情请点击 :玫瑰:",
                        "tag": "lark_md"
                    },
                    "url": "https://www.example.com",
                    "type": "default",
                    "value": {}
                }],
                "tag": "action"
            }],
            "header": {
                "title": {
                    "content": "今日报错推送",
                    "tag": "plain_text"
                }
            }
        }
    }
    requests.post(url=webhook, json=content, verify=False)
